package com.woniuxy.testDate;

/**
 * description: TestCanlendar <br>
 * date: 2022/2/2 1:13 下午 <br>
 * author: shesaifei <br>
 * version: 1.0 <br>
 */

import java.util.Calendar;
import java.util.GregorianCalendar;

/**
 * 测试日期类的使用
 */
public class TestCanlendar {
    public static void main(String[] args) {
        //获得日期的相关元素
        Calendar calendar = new GregorianCalendar(2022, 10, 9, 22, 10, 50);
        int year = calendar.get(Calendar.YEAR);
        int month = calendar.get(Calendar.MONTH);
        int day = calendar.get(Calendar.DATE);
        //星期几
        int weekday = calendar.get(Calendar.DAY_OF_WEEK);
        System.out.println(year);
        //0-11表示对应的几月份。0-1月，1月2月....12月
        System.out.println(month);
        System.out.println(weekday);
        System.out.println(day);
    }
}
